const state = {
  mealInfo:[],
  copies:[]
}
const mutations = {
  GETMEALINFO(state,mealInfo){
    state.mealInfo=mealInfo
  },
  GETSURPLUS(state,copies){
    state.copies=copies
    
  }
}
const actions = {
  //获取套餐
  async getMealInfo({commit}, params) {
    console.log('获取套餐',params)
    let result = await uni.$http.get('/app/meal_info')
    console.log('获取套餐',result)
    if (result.data.code == 200) {
      commit('GETMEALINFO',result.data.data)
      return 'ok'
    } else {
      return Promise.reject(new Error(result.data.msg));
    }
  },
  //获取剩余套餐
  async getSurplus({commit}) {
    let result = await uni.$http.get('/app/user-copies')
    console.log('获取剩余套餐',result)
    if (result.data.code == 200) {
      commit('GETSURPLUS',result.data.data)
      return 'ok'
    } else {
      return Promise.reject(new Error(result.data.msg));
    }
  },
  

}


//计算属性:在项目在中,为简化数据而生
const getters = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
